import 'dart:core';

import 'package:flutter_module/beans/base_bean.dart';
import 'package:flutter_module/util/string_utils.dart';

class Project extends BaseBean {
  ///唯一标识
  String uuid;

  ///项目名称
  String name;

  ///创建时间
  String createTime;

  ///项目描述信息
  String describe;

  ///项目是否显示
  bool visibility;

  ///任务圈
  String? geometry;

  ///任务圈显隐
  bool geometryVisibility;

  Project(
      {this.uuid = "",
      required this.name,
      this.createTime = "",
      this.describe = "",
      this.visibility = true,
      this.geometry,
      this.geometryVisibility = false}) {
    if (uuid == "") {
      uuid = StringUtil.createUUID();
    }
    if (createTime == "") {
      createTime = StringUtil.formatCurrentTime();
    }
  }

  @override
  Map<String, dynamic> toMap() {
    return {
      "uuid": uuid,
      "name": name,
      "createTime": createTime,
      "describe": describe,
      "visibility": visibility,
      "geometry": geometry,
      "geometryVisibility": geometryVisibility,
    };
  }

  factory Project.from(Map map) {
    return Project(
      uuid: map["uuid"],
      name: map["name"],
      createTime: map["createTime"],
      describe: map["describe"],
      visibility: map["visibility"],
      geometry: map["geometry"],
      geometryVisibility: map["geometryVisibility"],
    );
  }
}
